package com.engine.core.util;

import com.engine.query.cmd.GetByIdCommand;
import com.engine.query.cmd.QueryPageCommand;
import com.engine.query.cmd.QueryResourceCommand;
import com.engine.core.interceptor.ResponseCommand;

public enum QueryActionEnum {
    GETBYID("getById", GetByIdCommand.class,new String[]{QueryUtil.QUERY_ID,QueryUtil.QUERY_TABLE}),
    QUERY("query", QueryResourceCommand.class),
    QUERY_PAGE("queryPage", QueryPageCommand.class);


    private String action;
    private Class<? extends ResponseCommand> command;

    private String[] checkParams;


    QueryActionEnum(String action,Class<? extends ResponseCommand> command){
        this.action=action;
        this.command=command;
    }

    QueryActionEnum(String action,Class<? extends ResponseCommand> command,String[] checkParams){
        this.action=action;
        this.command=command;
        this.checkParams=checkParams;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public Class<? extends ResponseCommand> getCommand() {
        return command;
    }

    public void setCommand(Class<? extends ResponseCommand> command) {
        this.command = command;
    }

    public static QueryActionEnum get(String action){
        QueryActionEnum r=null;
        for (QueryActionEnum e:values()) {
            if(e.getAction().equalsIgnoreCase(action)){
                r=e;
            }
        }
        return r;
    }


}
